package com.tianpengtech.common.validator.rules.string;


import org.apache.commons.lang.StringUtils;

import com.tianpengtech.common.exception.ValidateException;
import com.tianpengtech.common.validator.AbstractRule;

public class StringMustBeRequired extends AbstractRule {

    public StringMustBeRequired(String v, String msg) {
        this.value = v;
        this.msg = msg;
    }

    @Override
    public boolean validate() throws ValidateException {
        String v = StringUtils.trim((String) this.value);
        if (StringUtils.isEmpty(v)) {
            throw new ValidateException(this.msg);
        }
        return true;
    }
}
